import axios from 'axios'

export function createOrder(data) {
  return axios.post('/api/order/create', data).then(res => res.data)
}

export function getOrderList(userId, status) {
  let url = `/api/order/list?userId=${userId}`
  if (status !== undefined) {
    url += `&status=${status}`
  }
  return axios.get(url).then(res => res.data)
}

export function getOrderDetail(orderNo) {
  return axios.get(`/api/order/detail?orderNo=${orderNo}`).then(res => res.data)
}

export function cancelOrder(orderNo) {
  return axios.put(`/api/order/cancel?orderNo=${orderNo}`).then(res => res.data)
}

export function payOrder(orderNo, paymentMethod) {
  return axios.put(`/api/order/pay?orderNo=${orderNo}&paymentMethod=${paymentMethod}`).then(res => res.data)
} 